﻿<%@ Page Language="C#" MasterPageFile="~/share/MainPage.Master" AutoEventWireup="true"
    CodeBehind="MDHomepage.aspx.cs" Inherits="AKMII.DMRA.Web.MDHomepage" Title="Agent Lead Order & Delivery System" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register TagPrefix="ajax" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="InfoContent" runat="server">
    <script type="text/javascript">
        var LockMonth;
        var MDRuleRepeatEnable;
        var curWeek;
        var curAgent;
        var curMonth;
        var curYear;
        var MDRuleEnable;

        function DisplayTooltip(value) {
            document.getElementById("divTooltip").style.display = value;
        }

        function showHistoryWindow(htmUrl) {
            var url = htmUrl;
            var winName = 'View Print Order History';
            var awidth = screen.availWidth / 6 * 3;
            var aheight = screen.availHeight / 5 * 3;
            var atop = (screen.availHeight - aheight) / 2;
            var aleft = (screen.availWidth - awidth) / 2;
            var param0 = "status=0,menubar=0,resizable=2,location=0,scrollbars=yes";
            var params = "top=" + atop + ",left=" + aleft + ",width=670,height=" + aheight + "," + param0;
            win = window.open(url, 'new', params + param0);
            win.focus();
        }
        function GoToMap(type) {
            if (type != 'reSelect' && type != 'reCities') {
                if (ConfirmForNextWeekOrAgent() == false){
                    return;
                }
            }

            if (type == 'reCities') {
                alert('Don\'t forget, the cities you selected are already highlighted. If you want to include those cities in your order you need to show them again. Select multiple files that are grouped together If you want to select multiple cities that are all grouped together:\n1.Select the first city and then press and hold the Shift key.\n2.While holding the shift key down click the last file. This will select all the cities in-between the first and last city.\n\nTo select multiple files that are not grouped together\n\nIf there are multiple cities you need to select but they are not grouped together:\n1.Select the first city you want to copy and then press and hold the Ctrl key.\n2.While holding down the Ctrl key, select each of the other cities you wish to select.')
            }

            PageMethods.TransferPara(type, callBacka);
        }
        function ConfirmForNextWeekOrAgent() {
            if (!confirm("You should not go to the next week or agent unless you have clicked the save button, otherwise the leadblocks won't be saved to the cart. Have you saved?(If you have not saved your assignments, select \"Cancel\")")) {
                return false;
            }

            var lbneighbor = document.getElementById("ctl00_InfoContent_lbNeighborLead");
            var lbactive = document.getElementById("ctl00_InfoContent_lbActiveLead");
            var lbbussiness = document.getElementById("ctl00_InfoContent_lbBussinessLead");
            var lblapse = document.getElementById("ctl00_InfoContent_lbLapseLead");
            var lbUpper = document.getElementById("ctl00_InfoContent_lblUpper").innerHTML;
            var lbLower = document.getElementById("ctl00_InfoContent_lblLower").innerHTML;

            MDRuleEnable = $('hiddenIsMDRuleEnalbe').value;
            if (MDRuleEnable == 'True') {
                if (parseInt(lbactive.innerHTML) > parseInt(lbUpper) || parseInt(lbactive.innerHTML) < parseInt(lbLower)) {
                    alert('The active stops must be between ' + lbLower + ' and ' + lbUpper + ',please select agian.');
                    return false;
                }
            }

            return true;
        }

        function NextWeek() {
            if (ConfirmForNextWeekOrAgent() == false) {
                return;
            }

            var lbneighbor = document.getElementById("ctl00_InfoContent_lbNeighborLead");
            var lbactive = document.getElementById("ctl00_InfoContent_lbActiveLead");
            var lbbussiness = document.getElementById("ctl00_InfoContent_lbBussinessLead");
            var lblapse = document.getElementById("ctl00_InfoContent_lbLapseLead");
            var lblCurWeek = document.getElementById("ctl00_InfoContent_lblInfoWeek");
            lbneighbor.innerHTML = 0;
            lbactive.innerHTML = 0;
            lblapse.innerHTML = 0;
            lbbussiness.innerHTML = 0;

            var currentWeek = parseInt(lblCurWeek.innerHTML);
            var weekcount = $('hiddenWeekCount').value;

            if (currentWeek < weekcount) {
                curWeek = currentWeek + 1;
                lblCurWeek.innerHTML = curWeek;
            }

            if (curWeek >= weekcount) {
                var btn = document.getElementById("btnNextWeeek");
                var btn1 = document.getElementById("btnweek");
                btn.setAttribute('disabled', 'disabled');
                btn1.disabled = false;
            }

            PageMethods.SetCurrentWeek(curWeek);
        }
        function callBacka(result) {
            window.location.href = 'orderMap.aspx';
        }

        function CallBckAgent(result) {
            curAgent = result;
        }
    </script>
    <br />
    <div class="leadinfo" style="position: relative">
        You are working on assignment:
        <br />
        Agent:<asp:Label ForeColor="Red" ID="lblInfoAgent" runat="server" Text="0"></asp:Label><br />
        Week:<asp:Label ForeColor="Red" ID="lblInfoWeek" runat="server" Text="0"></asp:Label><br />
        Active stops must be between
        <asp:Label ForeColor="Red" ID="lblLower" runat="server" Text="0"></asp:Label>
        and
        <asp:Label ForeColor="Red" ID="lblUpper" runat="server" Text="0"></asp:Label>.<br />
        Your total stops so far:<br />
        <asp:Label ForeColor="Red" ID="lbActiveLead" runat="server" Text="0"></asp:Label>
        Active;<br />
        <asp:Label ForeColor="Red" ID="lbLapseLead" runat="server" Text="0"></asp:Label>
        Lapsed;
        <br />
        <asp:Label ForeColor="Red" ID="lbNeighborLead" runat="server" Text="0"></asp:Label>
        Neighbor;
        <br />
        <asp:Label ForeColor="Red" ID="lbBussinessLead" runat="server" Text="0"></asp:Label>
        Business;
        <asp:Label ForeColor="Red" ID="lbSelected" runat="server" Visible="false"></asp:Label>
        <br />
        <div style="text-align: center">
            <input type="button" id="btnNextWeeek" value="Next Week" class="loginbuttonBtnx"
                onclick="NextWeek();" />
            <input type="button" id="btnweek" value="Next Agent or Month" class="loginbuttonBtnx"
                onclick="GoToMap('nextAgent');" />
            <input type="button" id="btnSelectWeek" value="Select Week" class="loginbuttonBtnx"
                onclick="GoToMap('reSelect');" />
            <input type="button" id="btnSelectCities" value="Select Cities" class="loginbuttonBtnx"
                onclick="GoToMap('reCities');" />
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="LinkContent" runat="server">
    <a id="breadcrumb_home" href="#">Home</a>&nbsp;&gt;&nbsp; <a id="A1" href="javascript:void(0);">
        Choose Leads</a>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="DetailsContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
    </asp:ScriptManager>
    <script type="text/javascript">
        function $(id) {
            return document.getElementById("ctl00_DetailsContent_" + id);
        }
        function UnSelectAll() {
            var table = $("DataList1");
            var checkboxs = table.getElementsByTagName("input");
            for (var i = 0; i < checkboxs.length; i++) {
                if (checkboxs[i].type == "checkbox" && !checkboxs[i].disabled) {
                    checkboxs[i].checked = false;
                }
            }
            changecolor();
        }
        function changecolor() {
            var table = $("DataList1");
            var hiddenNum = $("hiddenNum");
            var hiddenNum1 = $("hiddenActive");
            var hiddenNum2 = $("hiddenBussiness");
            var hiddenNum3 = $("hiddenLapse");
            var hiddenNum4 = $("hiddenNeighbor");
            var lbneighbor = document.getElementById("ctl00_InfoContent_lbNeighborLead");
            var lbactive = document.getElementById("ctl00_InfoContent_lbActiveLead");
            var lbbussiness = document.getElementById("ctl00_InfoContent_lbBussinessLead");
            var lblapse = document.getElementById("ctl00_InfoContent_lbLapseLead");
            var otherpageSelected = parseInt(hiddenNum.value, 10);
            var otherpageSelected1 = parseInt(hiddenNum1.value, 10);
            var otherpageSelected2 = parseInt(hiddenNum2.value, 10);
            var otherpageSelected3 = parseInt(hiddenNum3.value, 10);
            var otherpageSelected4 = parseInt(hiddenNum4.value, 10);
            var sumactive = 0;
            var sumbussiness = 0;
            var sumlapse = 0;
            var sumneighbor = 0;
            var sum = 0;
            for (var j = 1; j < table.rows.length; j++) {
                var checkboxs = table.rows[j].getElementsByTagName("input");
                for (var i = 0; i < checkboxs.length; i++) {
                    if (checkboxs[i].type == "checkbox" && !checkboxs[i].disabled) {
                        var userAssign = checkboxs[1];
                        if (checkboxs[i].checked) {
                            table.rows[j].style.backgroundColor = "orange";
                            if (IsCurWeekLeads(userAssign.value)) {
                                if (checkboxs[i].id.substring(checkboxs[i].id.length - 4) == "Buss") {
                                    var rowBussiness = parseInt(table.rows[j].cells[11].innerHTML, 10);
                                    sumbussiness = sumbussiness + rowBussiness;
                                }
                                else {
                                    var rowActiveLeads = parseInt(table.rows[j].cells[8].innerHTML, 10);
                                    var rowLapseLeads = parseInt(table.rows[j].cells[9].innerHTML, 10);
                                    var rowNeighbor = parseInt(table.rows[j].cells[10].innerHTML, 10);
                                    sumactive = sumactive + rowActiveLeads;
                                    sumlapse = sumlapse + rowLapseLeads;
                                    sumneighbor = sumneighbor + rowNeighbor;
                                }
                            }
                        }
                    }
                    else if (i > 0) {
                        if (!(!checkboxs[i - 1].disabled && checkboxs[i - 1].checked)) {
                            if (table.rows[j].style.backgroundColor != "#edf5f8") {
                                table.rows[j].style.backgroundColor = "white";
                                if (table.rows[j].cells[0].innerText == table.rows[j - 1].cells[0].innerText && table.rows[j - 1].style.backgroundColor != "orange") {
                                    table.rows[j].style.backgroundColor = table.rows[j - 1].style.backgroundColor;
                                }
                                else if (j < table.rows.length - 1) {
                                    if (j < 100 && table.rows[j].cells[0].innerText == table.rows[j + 1].cells[0].innerText && table.rows[j + 1].style.backgroundColor != "orange") {
                                        table.rows[j].style.backgroundColor = table.rows[j + 1].style.backgroundColor;
                                    }

                                    else {
                                        if (table.rows[j - 1].style.backgroundColor == "white") {
                                            table.rows[j].style.backgroundColor = "#edf5f8"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            lbbussiness.innerHTML = sumbussiness + otherpageSelected2;
            lbneighbor.innerHTML = sumneighbor + otherpageSelected4;
            lbactive.innerHTML = sumactive + otherpageSelected1;
            lblapse.innerHTML = sumlapse + otherpageSelected3;
        }

        function CheckSelected() {
            var sumALN = 0;
            var sumBuss = 0;
            var hiddenNum = $("hiddenNum");
            var hiddenNum2 = $("hiddenBussiness");
            var otherpageSelected = parseInt(hiddenNum.value, 10);
            var otherpageSelected2 = parseInt(hiddenNum2.value, 10);
            var table = $("DataList1");
            var checknull = 0;
            for (var j = 1; j < table.rows.length; j++) {
                var checkboxs = table.rows[j].getElementsByTagName("input");
                for (var i = 0; i < checkboxs.length; i++) {
                    if (checkboxs[i].type == "checkbox" && !checkboxs[i].disabled) {
                        var userAssign = checkboxs[1];

                        if (checkboxs[i].checked && IsCurWeekLeads(userAssign.value)) {
                            if (checkboxs[i].id.substring(checkboxs[i].id.length - 4) == "Buss") {
                                var rowBussinessLeads = parseInt(table.rows[j].cells[11].innerHTML, 10);
                                sumBuss = sumBuss + rowBussinessLeads;
                            }
                            else {
                                var rowActiveLeads = parseInt(table.rows[j].cells[8].innerHTML, 10);
                                var rowLapseLeads = parseInt(table.rows[j].cells[9].innerHTML, 10);
                                var rowNeighborLeads = parseInt(table.rows[j].cells[10].innerHTML, 10);
                                var rowleads = rowActiveLeads + rowLapseLeads;
                                checknull = checknull + rowleads;
                                sumALN = sumALN + rowleads;
                            }
                        }
                    }
                }
            }

            var lbActive = document.getElementById("ctl00_InfoContent_lbActiveLead");
            var lbUpper = document.getElementById("ctl00_InfoContent_lblUpper");
            var lbLower = document.getElementById("ctl00_InfoContent_lblLower");

            MDRuleEnable = $('hiddenIsMDRuleEnalbe').value;
            if (MDRuleEnable == 'True') {
                if (parseInt(lbActive.innerHTML) > parseInt(lbUpper.innerHTML) || parseInt(lbActive.innerHTML) < parseInt(lbLower.innerHTML)) {
                    alert('The active stops must be between ' + lbLower.innerHTML + ' and ' + lbUpper.innerHTML + ',please select agian.');
                    return false;
                } 
            }

            sumALN = sumALN + otherpageSelected;
            sumBuss = sumBuss + otherpageSelected2;
            if (!confirm("You are about to save " + sumALN + " active & lapse leads and " + sumBuss + " Business leads  to your cart. Did you want to do that?")) {
                return false;
            }
        }

        function updateWeek(curChk, zipId) {

            var table = $("DataList1");
            for (var j = 1; j < table.rows.length; j++) {
                if (j == 100) {
                    break;
                }
                var checkboxs = table.rows[j].getElementsByTagName("input");
                var zipID = checkboxs[0];
                if (parseInt(zipId) == parseInt(zipID.value)) {
                    var userAssign = checkboxs[1];
                    if (curChk.checked) {

                        userAssign.value = curWeek + ' ' + curAgent;
                    }
                    else {
                        userAssign.value = '';
                    }
                }

            }
        }
        function SetCheckBoxEnable() {
            var table = $("DataList1");
            var index = 0;
            var tableLength = table.rows.length;
            if (table.rows[tableLength - 1].cells.length < 2) {
                tableLength = tableLength - 1;
            }
            if (table != null) {
                for (var i = 11; i <= table.rows[0].cells.length - 1; i++) {
                    if (table.rows[0].cells[i].style.color == "black") {
                        index = i;
                    }
                }
                for (var j = 0; j < tableLength; j++) {

                    var checkboxs = table.rows[j].cells[index].getElementsByTagName("input");
                    for (var i = 0; i < checkboxs.length; i++) {
                        if (checkboxs[i].type == "checkbox") {
                            checkboxs[i].disabled = false;
                        }
                    }
                    checkboxs = table.rows[j].cells[index - 1].getElementsByTagName("input")
                    for (var i = 0; i < checkboxs.length; i++) {
                        if (checkboxs[i].type == "checkbox") {
                            checkboxs[i].disabled = false;
                        }
                    }
                }
            }
        }

        window.onload = function MoveCurrentMonth() {
            altercolors();
            var isOrder = $("hiddenIsOrder").value;
            var btnUnSelect = $("btnUnSelect");
            var btnSave = $("btnSave");
            var btnFilter = $("btnFilter");
            var table = $("DataList1");
            if (isOrder == "1") {
                btnUnSelect.disabled = true;
                btnSave.disabled = true;

            }
            var div1 = document.getElementById("contentContainnerDiv");
            div1.scrollLeft = 800;
            var inputComboBox = document.getElementById("ctl00_DetailsContent_comboBox_Button");
            if (window.addEventListener) { // Mozilla, Netscape, Firefox   
            } else { // IE
                inputComboBox.attachEvent('onclick', function () {
                    document.getElementById("ctl00_DetailsContent_comboBox_OptionList").style.width = "68px";
                });
            }
            setLastOrderEnable();
            PageMethods.GetCurWeek(CallBackWeek);
            PageMethods.GetAgent(CallBckAgent);
        }
    
        function CallBackWeek(result) {

            var week = new Array();
            week = result.split('|');

            curWeek = parseInt(week[0]);
            var weekCount = parseInt(week[1]);
            var btn = document.getElementById("btnNextWeeek");
            var btn1 = document.getElementById("btnweek");
            if (curWeek == weekCount) {
                btn.setAttribute('disabled', 'disabled');
            }
            else if (curWeek < weekCount) {
                btn1.setAttribute('disabled', 'disabled');
            }
        }

        function altercolors() {
            var table = $("DataList1");
            var colors = "#edf5f8";
            if (table != null) {
                for (var i = 12; i <= table.rows[0].cells.length - 1; i++) {
                    if (table.rows[0].cells[i].style.color == "black") {
                        index = i;
                    }
                }
                for (var j = 1; j < table.rows.length - 1; j++) {
                    if (table.rows[j].style.backgroundColor != "orange") {
                        if (table.rows[j].cells.length > 2) {
                            if (table.rows[j].cells[0].innerText != table.rows[j - 1].cells[0].innerText) {
                                if (colors == "#edf5f8") {
                                    colors = "white";
                                }
                                else {
                                    colors = "#edf5f8";
                                }
                            }
                            table.rows[j].style.backgroundColor = colors;
                        }
                    }
                }
            }
        }
        function setLastOrderEnable() {

            var table = $("DataList1");
            if (table != null) {
                for (var j = 1; j <= table.rows.length - 1; j++) {
                    if (j == 100) {
                        break;
                    }
                    var tmpHtml = table.rows[j].cells[0].innerHTML;
                    var zipId = tmpHtml.substring(tmpHtml.indexOf('value="') + 'value="'.length, tmpHtml.indexOf('" type="hidden"'));

                    if (!isNaN(parseInt(zipId))) {
                        PageMethods.GetLastOrderDate(zipId, j, callBackOrderEnable);
                    }

                }
            }
        }
        function callBackOrderEnable(result) {

            if (result != '' || result != null) {
                var paras = new Array();
                paras = result.split('|');
                MDRuleRepeatEnable = $('hiddenIsRuleRepeatEnalbe').value;
                if (MDRuleRepeatEnable && !IsLockOrder(paras[0])) {
                    var table = $("DataList1");
                    var checkboxs = table.rows[paras[1]].getElementsByTagName("input");
                    for (var i = 0; i < checkboxs.length; i++) {
                        if (checkboxs[i].type == "checkbox" && !checkboxs[i].disabled) {
                            checkboxs[i].disabled = true;
                        }
                    }
                }
            }

        }
        function setCheck(curChk) {
            var table = $("DataList1");
            var checknull = 0;
            var breakKey = false;
            for (var j = 1; j < table.rows.length; j++) {
                var checkboxs = table.rows[j].getElementsByTagName("input");
                for (var i = 0; i < checkboxs.length; i++) {
                    if (checkboxs[i].type == "checkbox" && !checkboxs[i].disabled) {
                        if (checkboxs[i].id == curChk.id) {
                            if (checkboxs[i].id.substring(checkboxs[i].id.length - 4) == "Buss") {
                                if (curChk.checked) {
                                    checkboxs[i - 1].checked = true;
                                }
                                else {
                                    checkboxs[i - 1].checked = false;
                                }

                            }
                            else {
                                if (curChk.checked) {
                                    checkboxs[i + 1].checked = true;
                                }
                                else {
                                    checkboxs[i + 1].checked = false;
                                }
                            }
                            breakKey = true;
                            break;
                        }
                    }
                }

                if (breakKey) {
                    break;
                }
            }
            changecolor();
        }
        function IsLockOrder(LastOrderDate) {
            if (LastOrderDate != null && LastOrderDate.length >= 6) {
                var LastOrderMonth = LastOrderDate.substring(0, 2);
                var LastOrderYear = LastOrderDate.substring(2, 6);
                diff = 0;
                curMonth = $('hiddenMonth').value;
                curYear = $('hiddenYear').value;
                LockMonth = $('hiddenLockMonth').value;
                if (parseInt(curYear) > parseInt(LastOrderYear)) {
                    diff = 12 - parseInt(LastOrderMonth) + parseInt(curMonth);
                }
                else {
                    diff = parseInt(curMonth) - parseInt(LastOrderMonth);
                }

                if (diff >= LockMonth) {
                    return true;
                }
                else {
                    return false;
                }
            }
            return true;
        }

        function IsCurWeekLeads(assign) {
            if (assign == null || assign == '') {
                return false;
            }
            var assignmentName = assign.substring(assign.indexOf(' ') + 1, assign.length);
            assignmentName = assignmentName.replace(/\s+$|^\s+/g, ""); //trim
            var week = assign.split(' ')[0];
            if (assignmentName == curAgent && parseInt(week) == parseInt(curWeek)) {
                return true;
            }
            return false;
        }
        function showDLA() {
            alert('This assignment contains leads that fall into any of the following classifications: Leads having a P.O. Box address, an undeliverable USPS address or a Do Not Contact record. ');
        }
    </script>
    <div class="addmd">
        <asp:Button ID="btnUnSelect" CssClass="loginbuttonBtn" runat="server" Text="Unselect All"
            OnClick="btnUnSelect_Click" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input id="input1" type="button" value="View/Print OrderHistory" class="loginbuttonBtn1"
            onclick="showHistoryWindow('ViewOrderHistory.aspx');" />
        &nbsp;&nbsp;&nbsp;&nbsp;<asp:Button OnClientClick="return CheckSelected();" ID="btnSave"
            CssClass="loginbuttonBtn" runat="server" Text="Save Selections" OnClick="btnSave_Click" />
        <asp:HiddenField ID="hiddenIsOrder" runat="server" />
        <%--     <asp:HiddenField ID="hiddenNumallvalue" runat="server" />--%>
        <asp:HiddenField ID="hiddenNum" runat="server" />
        <asp:HiddenField ID="hiddenActive" runat="server" />
        <asp:HiddenField ID="hiddenBussiness" runat="server" />
        <asp:HiddenField ID="hiddenLapse" runat="server" />
        <asp:HiddenField ID="hiddenNeighbor" runat="server" />
        <asp:HiddenField ID="hiddenEstimate" runat="server" />
        <asp:HiddenField ID="hiddenMonth" runat="server" />
        <asp:HiddenField ID="hiddenYear" runat="server" />
        <asp:HiddenField ID="hiddenLockMonth" runat="server" />
        <asp:HiddenField ID="hiddenIsRuleRepeatEnalbe" runat="server" />
        <asp:HiddenField ID="hiddenWeekCount" runat="server" />
        <asp:HiddenField ID="hiddenIsMDRuleEnalbe" runat="server" />
    </div>
    <div class="filtercontainer">
        Zip:<%--<asp:TextBox CssClass="filterinput" ID="txtFilterZip" runat="server"></asp:TextBox>--%>
        <ajax:ComboBox ID="comboBox" runat="server" DropDownStyle="DropDown" AutoCompleteMode="Suggest"
            ItemInsertLocation="Append">
        </ajax:ComboBox>
        &nbsp;&nbsp; County:
        <asp:DropDownList Width="78px" ID="ddlFilterCounty" runat="server">
        </asp:DropDownList>
        &nbsp;&nbsp;State:
        <asp:DropDownList Width="58px" ID="ddlFilterState" runat="server">
        </asp:DropDownList>
        &nbsp;&nbsp; City:
        <asp:DropDownList Width="80px" ID="ddlFilterCity" runat="server">
        </asp:DropDownList>
        <%--&nbsp;&nbsp; Territory:
        <asp:DropDownList Width="60px" ID="ddlFilterTerr" runat="server">
        </asp:DropDownList>--%>
        &nbsp;&nbsp;
        <asp:Button ID="btnFilter" runat="server" CssClass="filterbutton" Text="Filter" OnClientClick="SetCheckBoxEnable();"
            OnClick="btnFilter_Click" />&nbsp;&nbsp;
        <asp:Button ID="btnClear" runat="server" CssClass="filterbutton" Text="Clear" OnClientClick="SetCheckBoxEnable();"
            OnClick="btnClear_Click" />
    </div>
    <div id="contentContainnerDiv" class="contentContainnerDiv">
        <asp:GridView AllowPaging="True" ID="DataList1" Width="1020px" runat="server" AutoGenerateColumns="False"
            PageSize="100" OnPageIndexChanging="DataList1_PageIndexChanging" DataKeyNames="ZipId"
            AllowSorting="True" OnSorting="GdvSort" EnableModelValidation="True" 
            onrowdatabound="DataList1_RowDataBound">
            <HeaderStyle CssClass="ItemListHeaderRow" />
            <Columns>
                <asp:TemplateField HeaderText="Zip Code" SortExpression="ZipName">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ZipName") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("ZipName") %>'></asp:Label>
                        <asp:HiddenField ID="zipID" runat="server" Value='<%# Bind("ZipId") %>' />
                        <asp:HiddenField ID="AssignMent" runat="server" Value='<%# Bind("UserAssigned") %>' />
                    </ItemTemplate>
                    <HeaderStyle CssClass="BorderLeft22" Width="40px" />
                    <ItemStyle CssClass="subheader22" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="DLA">
                
                <ItemTemplate>
                        <asp:Label ID="LabelDLA" runat="server" ></asp:Label>
                        <asp:HiddenField ID="ISDLA" runat="server" Value='<%# Bind("IsDLA") %>' />
                      
                </ItemTemplate>
                 <HeaderStyle CssClass="BorderLeft22" Width="40px" />
                    <ItemStyle CssClass="subheader22" />
                </asp:TemplateField>
                <asp:BoundField HeaderText="County" DataField="County">
                    <HeaderStyle CssClass="BorderLeft22" Width="80px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="State" DataField="State">
                    <HeaderStyle CssClass="BorderLeft22" Width="45px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Preferred City" DataField="City">
                    <HeaderStyle CssClass="BorderLeft22" Width="65px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Alternate City" HtmlEncode="false" DataField="secondarycity">
                    <HeaderStyle CssClass="headrightborder" Width="65px"></HeaderStyle>
                    <ItemStyle CssClass="blackrightborder"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Division" DataField="Division">
                    <HeaderStyle CssClass="BorderLeft22" Width="55px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Market" DataField="Market">
                    <HeaderStyle CssClass="BorderLeft22" Width="55px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
               <%-- <asp:BoundField HeaderText="Terr" DataField="Territory">
                    <HeaderStyle CssClass="BorderLeft22" Width="40px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>--%>
                <asp:BoundField HeaderText="Active Count" HtmlEncode="false" DataField="ActiveLeadCount">
                    <HeaderStyle CssClass="BorderLeft22" Width="50px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Lapsed Count" HtmlEncode="false" HeaderStyle-CssClass="BorderLeft"
                    ItemStyle-CssClass="subheader" DataField="LapsedLeadCount">
                    <HeaderStyle CssClass="BorderLeft22" Width="50px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Neighbor Count" HtmlEncode="false" DataField="NeighborLeadCount">
                    <HeaderStyle CssClass="BorderLeft22" Width="60px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField HeaderText="Business Count" HtmlEncode="false" DataField="BusinessLeadCount">
                    <HeaderStyle CssClass="BorderLeft22" Width="65px"></HeaderStyle>
                    <ItemStyle CssClass="subheader22"></ItemStyle>
                </asp:BoundField>
                 
               
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-4)%>
                        ALN
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbFeb" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-4)%>
                        Bus
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbFebBuss" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-3)%>
                        ALN
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbMar" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-3)%>
                        Bus
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbMarBuss" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-2)%>
                        ALN
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbApr" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-2)%>
                        Bus
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbAprBuss" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-1)%>
                        ALN
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbMay" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(-1)%>
                        Bus
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbMayBuss" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(0)%>
                        ALN
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbJun" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle CssClass="subheader" />
                    <HeaderStyle CssClass="BorderLefthomepage" Width="50px" />
                    <HeaderTemplate>
                        <%=GetLatestMonthByCurrentMonth(0)%>
                        Bus
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chbJunBuss" Enabled="false" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerStyle CssClass="pagestyle" />
            <EmptyDataTemplate>
                <table class="leadtable" cellspacing="0" border="1" style="width: 1250px;">
                    <tr class="ItemListHeaderRow">
                        <th class="BorderLefthomepage">
                            Zip Co de
                        </th>
                        <th class="BorderLefthomepage">
                            County
                        </th>
                        <th class="BorderLefthomepage">
                            State
                        </th>
                        <th class="BorderLefthomepage">
                            City
                        </th>
                        <th class="BorderLefthomepage">
                            Division
                        </th>
                        <th class="BorderLefthomepage">
                            Market
                        </th>
                      <%--  <th class="BorderLefthomepage">
                            Terr
                        </th>--%>
                        <th class="BorderLefthomepage">
                            Active<br />
                            Count
                        </th>
                        <th class="BorderLefthomepage">
                            Lapsed<br />
                            Count
                        </th>
                        <th class="BorderLefthomepage">
                            Business<br />
                            Count
                        </th>
                        <th class="BorderLefthomepage">
                            Neighbor<br />
                            Count
                        </th>
                      
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(4)%>
                            ALN
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(4)%>
                            Bus
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(3)%>
                            ALN
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(3)%>
                            Bus
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(2)%>
                            ALN
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(2)%>
                            Bus
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(1)%>
                            ALN
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(1)%>
                            Bus
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(0)%>
                            ALN
                        </th>
                        <th class="BorderLefthomepage">
                            <%=GetLatestMonthByCurrentMonth(0)%>
                            Bus
                        </th>
                    </tr>
                    <tr>
                        <td class="subheader" colspan="25">
                            There is no record!
                        </td>
                    </tr>
                </table>
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
</asp:Content>